#include "StdAfx.h"
#include "EditorFactory.h"
#include "SelectEditor.h"


CEditorFactory::CEditorFactory(void)
{
}

CEditorFactory::~CEditorFactory(void)
{
}

void CEditorFactory::Initialize()
{
	
}

CAnyEditor* CEditorFactory::CreateEditor(const CString& szId, CAnyView* pView)
{
	ASSERT(pView);
	if(NULL == pView)
		return NULL;

	CAnyEditor* pEditor = CreateObject(szId);
	if(!pEditor)
	{
		pEditor = new CSelectEditor();
	}
	pEditor->Initialize(pView);
	return pEditor;
}

//////////////////////////////////////////////////////////////////////////

CRegEditorHelper::CRegEditorHelper(const CString& guid, CEditorCreator* pEditorCreator)
:m_Guid(guid)
{
	RegisterEditor(pEditorCreator);
}

CRegEditorHelper::~CRegEditorHelper()
{
	//GetEditorFactory().UnRegisterObject(m_Guid);
}

void CRegEditorHelper::RegisterEditor(CEditorCreator* pEditorCreator)
{
	bool bResult = GetEditorFactory().RegisterObject(m_Guid, pEditorCreator);
	ASSERT(bResult);
}